<?php

 ini_set('date.timezone','Asia/Shanghai');

//时间处理区
function TimeFomat($time){
	$hour=date('g', strtotime($time));
	$ampm=date('a', strtotime($time));
	$time=date('Y年m月d日', strtotime($time));
	switch ($ampm){
	case "pm":
		$text=pm($hour);
		break;
	case "am":
		$text=am($hour);
		break;
	}
	echo $time.$text.$hour."点";

}

function get_day_of_week()
{
    $now = time();
    $dow = strftime('%u', $now);
    return intval($dow);
}

function timetips(){
	$hour=date('H');
	switch ($hour){
		case  $hour <= 4 :
			$text='凌晨';break;		
		case  $hour <= 8 :
			$text='早晨';break;		
		case  $hour < 12 :
			$text='早上';break;
		case  $hour == 12 :
			$text='中午';break;		
		case  $hour <= 17 :
			$text='下午';break;		
		case  $hour <= 19 :
			$text='黄昏';break;		
		case  $hour <= 23 :
			$text='晚上';break;		
		case  $hour == 24 :
			$text='深夜';break;		
	}
	return $text;
}




/**
 * Get the week start and end from the datetime or date string from mysql.
 *
 * @since 0.71
 *
 * @param string $mysqlstring Date or datetime field type from mysql.
 * @param int $start_of_week Optional. Start of the week as an integer.
 * @return array Keys are 'start' and 'end'.
 */
function get_weekstartend( $mysqlstring, $start_of_week = '' ) {
	$my = substr( $mysqlstring, 0, 4 ); // Mysql string Year
	$mm = substr( $mysqlstring, 8, 2 ); // Mysql string Month
	$md = substr( $mysqlstring, 5, 2 ); // Mysql string day
	$day = mktime( 0, 0, 0, $md, $mm, $my ); // The timestamp for mysqlstring day.
	$weekday = date( 'w', $day ); // The day of the week from the timestamp
	if ( !is_numeric($start_of_week) )
		$start_of_week = get_option( 'start_of_week' );

	if ( $weekday < $start_of_week )
		$weekday += 7;

	$start = $day - 86400 * ( $weekday - $start_of_week ); // The most recent week start day on or before $day
	$end = $start + 604799; // $start + 7 days - 1 second
	return compact( 'start', 'end' );
}